//
//  DNFeedingManagerTests.m
//  DanoneEA
//
//  Created by Senela on 16/10/31.
//  Copyright © 2016年 翔傲科技. All rights reserved.
//

#import <XCTest/XCTest.h>
#import "DNFeedingManager.h"
#import "DNFeedingDao.h"

@interface DNFeedingManagerTests : XCTestCase
{
    DNFeedModel  *feedModel;
    DNFeedModel  *feedModel1;
}
@end

@implementation DNFeedingManagerTests

- (void)setUp {
    [super setUp];
    // Put setup code here. This method is called before the invocation of each test method in the class.
    
    feedModel = [[DNFeedModel alloc] init];
    feedModel.appId =[NSString stringWithFormat:@"%f", [[NSDate date] timeIntervalSince1970]];
    feedModel.createTime =[NSString stringWithFormat:@"%.0f", [[NSDate date] timeIntervalSince1970]];
    feedModel.numOfStuFor = @"1";
    feedModel.numOfBreFee = @"2";
    
    feedModel1 = [[DNFeedModel alloc] init];
    feedModel1.appId =[NSString stringWithFormat:@"%f", [[NSDate date] timeIntervalSince1970]];
    feedModel1.createTime =[NSString stringWithFormat:@"%.0f", [[NSDate date] timeIntervalSince1970]];
    feedModel1.numOfStuFor = @"4";
    feedModel1.numOfBreFee = @"5";
}

- (void)tearDown {
    // Put teardown code here. This method is called after the invocation of each test method in the class.
    [super tearDown];
}

- (void)testExample {
    // This is an example of a functional test case.
    // Use XCTAssert and related functions to verify your tests produce the correct results.
}

- (void)testPerformanceExample {
    // This is an example of a performance test case.
    [self measureBlock:^{
        // Put the code you want to measure the time of here.
    }];
}

-(void)test1AddSuc
{
    [[DNDataBase shareInstance] clearAllTableData];
    // 场景一： 成功－ 新增feeding diary
    BOOL ret = [[DNFeedingManager sharedInstance] addDiary:feedModel];
    XCTAssertEqual(ret, YES, @"add feeding Diary failed!");
    
}



-(void)test2ModifySuc
{
    // 场景二： 成功－ 编辑feeding diary
    feedModel.numOfOthForFee = @"3";
    feedModel.numOfBOTWOT = @"4";
    feedModel.modifyReason = @"modify reason";
    BOOL ret = [[DNFeedingManager sharedInstance] modifyDiary:feedModel];
    XCTAssertEqual(ret, YES, @"modify feeding Diary failed!");
 
}


-(void)test3DeleteSuc
{
    // 场景三： 成功－ 删除feeding diary
    feedModel.deleteReason = @"delete reason";
    BOOL ret = [[DNFeedingManager sharedInstance] deleteDiary:feedModel];
    XCTAssertEqual(ret, YES, @"delete feeding Diary failed!");

}


-(void)test4SaveArr
{
    [[DNDataBase shareInstance] clearAllTableData];
    
    NSMutableArray *feedingArr = [NSMutableArray array];
    NSTimeInterval timeInterval =  [[NSDate date] timeIntervalSince1970];
    for(int i=0; i<60; i++)
    {
        DNFeedModel  *feedTempModel = [[DNFeedModel alloc] init];
        feedTempModel.numOfStuFor = @"1";
        feedTempModel.numOfBreFee = @"2";
        //CHG Jery 2016-11-02  修改创建时间超出当前时间的问题
        feedTempModel.appId =[NSString stringWithFormat:@"%.0f", timeInterval - i];
        feedTempModel.createTime =[NSString stringWithFormat:@"%.0f", timeInterval - i];
        feedTempModel.status = [NSNumber numberWithInt:OPStatus_ADD];
        
        [feedingArr addObject:feedTempModel];
    }
    
    BOOL ret =[[DNFeedingManager sharedInstance] saveFeedingDairyArrToLocalDB:feedingArr];
    XCTAssertEqual(ret, YES, @"DNFeedingManager-- saveFeedingDairyArrToLocalDB error");
    
    NSMutableArray *displayArr = [[[DNFeedingDao alloc] init] getAppDisplayObjectModel];
    XCTAssertEqual(displayArr.count, 60, @"DNStoolManager-- getAppDisplayObjectModel error");
}





@end
